package com.fbs.wowo.userBuy.web;


import com.fbs.wowo.base.BaseController;
import com.fbs.wowo.base.Response;
import com.fbs.wowo.userBuy.entity.UserBuy;
import com.fbs.wowo.userBuy.service.UserBuyService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@RequestMapping("userBuy")
@Controller
public class UserBuyController extends BaseController {

    @Resource
    private UserBuyService userBuyService;

    /**
     * 添加购买
     * @param userBuy
     * @return
     */
    @PostMapping("insertUserBuy")
    @ResponseBody
    public Response insertUserBuy(UserBuy userBuy){
        userBuyService.insertSelective(userBuy);
        return success();
    }

    /**
     * 更新
     * @param userBuy
     * @return
     */
    @PostMapping("updateUserBuy")
    @ResponseBody
    public Response updateUserBuy(UserBuy userBuy){
        userBuyService.updateByPrimaryKeySelective(userBuy);
        return success();
    }

    /**
     * 查询
     * @param userId
     * @param buyId
     * @return
     */
    @GetMapping("findUserBuy")
    @ResponseBody
    public Response findUserBuy(String userId, String buyId){
        UserBuy userBuy = userBuyService.selectByPrimaryKey(userId, buyId);
        return success(userBuy);
    }


}
